﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dominio;

namespace Persistencia
{
    abstract class Broker
    {
        protected ConexionBD conn;

        public static Broker crearBroker(Object o)
        {
            Broker broker = null;
            if (o.GetType().IsInstanceOfType(new PlanDePago()))
            {
                broker = new BrokerPlanDePago();
            }
            if (o.GetType().IsInstanceOfType(new Cliente()))
            {
                broker = new BrokerCliente();
            }
            if (o.GetType().IsInstanceOfType(new Proveedor()))
            {
                broker = new BrokerProveedor();
            }
            if (o.GetType().IsInstanceOfType(new Articulo()))
            {
                broker = new BrokerArticulo();
            }
            if (o.GetType().IsInstanceOfType(new IVA()))
            {
                broker = new BrokerIVA();
            }
            if (o.GetType().IsInstanceOfType(new MedioDePago()))
            {
                broker = new BrokerMedioDePago();
            }
            if (o.GetType().IsInstanceOfType(new TipoDocumento()))
            {
                broker = new BrokerTipoDocumento();
            }
            return broker;
        }

        //agrega el objeto en la base
        public abstract void add(object o);

        //modifica el objeto en la base
        public abstract void update(object o);

        //elimina el objeto de la base
        public abstract void delete(object o);

        //recupera los datos del objeto de la base
        public abstract void bringData(object o);

        //obtiene todos los objetos de ese tipo de la base
        public abstract List<Object> bringList(Object o);

        //obtiene el ultimo id de ese tipo de objetos de la base
        public abstract int bringLastId();
    }
}
